package com.diaohw.platform.framework.db.flex.listener;

import com.diaohw.platform.common.obj.thread.LoginThread;
import com.diaohw.platform.framework.db.flex.obj.model.BaseModel;
import com.mybatisflex.annotation.UpdateListener;

import java.time.LocalDateTime;

public class GlobalUpdateListener implements UpdateListener {


    @Override
    public void onUpdate(Object entity) {
        if (entity instanceof BaseModel base) {
            if (LoginThread.isLogin()){
                base.setUpdatedBy(LoginThread.getLoginId());
            }
            base.setUpdatedTime(LocalDateTime.now());
        }
    }
}
